{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "986f2ef4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle\n",
    "\n",
    "class Point2D(object):\n",
    "    def __init__(self,x,y):\n",
    "        self.x=x\n",
    "        self.y=y\n",
    "    def __repr__(self):\n",
    "        return \"Point({0.x!r}, {0.y!r})\".format(self) \n",
    "    def show_point(self):\n",
    "        return (self.x,self.y)\n",
    "    def lenth(self):\n",
    "        return 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "56725e52",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Point3D(object):\n",
    "    def __init__(self,x,y,z):\n",
    "        self.x=x\n",
    "        self.y=y\n",
    "        self.z=z\n",
    "    def __repr__(self):\n",
    "        return \"Point({0.x!r}, {0.y!r}, {0.z!r})\".format(self)\n",
    "    def show_point(self):\n",
    "        return (self.x,self.y,self.z)\n",
    "    def lenth(self):\n",
    "        return 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "dd7c74a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "class PointList:\n",
    "    def __init__(self,lis): \n",
    "        self.__lis = lis\n",
    "    \n",
    "    def read_list(self):  \n",
    "        for item in self.__lis:\n",
    "            assert item.lenth()==2 or item.lenth()==3, 'This is not valid input!'\n",
    "        return self.__lis\n",
    "\n",
    "    \n",
    "    def write_list(self,point): \n",
    "        self.__lis.append(point)\n",
    "    \n",
    "    def export_pickle(self,file_name): \n",
    "        file = open(file_name,'wb')\n",
    "        pickle.dump(self.__lis,file)\n",
    "        file.close()\n",
    "    \n",
    "    def import_pickle(self,file_name): \n",
    "        file = open(file_name,'rb')\n",
    "        lis1 = pickle.load(file)\n",
    "        print(lis1)\n",
    "        file.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50e7eaab",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
